{% extends "home/home.html" %}
{% load i18n %}

{% block head_title%}Carrito{% endblock %}

{% block content %}
<div id="content">
    <h1>Carrito de Compra &nbsp;</h1>
    
    <form enctype="multipart/form-data" method="POST" action="">{% csrf_token %}
        <div class="cart-info">
        
        
            <table>
                <thead>
                    <tr>
                        <td class="image">Imagen</td>
                        <td class="name">Producto</td>
                        <td class="quantity">Cantidad</td>
                        <td class="price">Precio de Unidad</td>
                        <td class="total">Total</td>
                    </tr>
                </thead>
                
                <tbody>
                {% for item in cart %}
                <tr>
                  <td class="image">
                      <a href=""><img src="{{MEDIA_URL}}{{item.product.image}}" alt="" height="45" width="45"/></a>
                  </td>
                  <td class="name">
                      <a href="">{{item.product.mutation}} </a>
                  </td>                  
                  <td class="quantity">
                  <form enctype="multipart/form-data" method="POST" action="">{% csrf_token %}
                      <input type="text" size="1" readonly="readonly" value="{{item.quantity}}" id="quantityform" class="w30">&nbsp;
                      <!--   <input type="image" title="Update" alt="Update" src="{{STATIC_URL}}img/update.png">&nbsp;--> 
                  </form>
                      <a href="{%  url 'apps.catalog.views.remove_from_cart' item.product.id %}"><img title="Remove" alt="Remove" src="{{STATIC_URL}}img/remove.png"></a>
                  </td>
                  <td class="price">{{item.unit_price}}€</td>
                  <td class="total">{{item.total_price}}€</td>
                </tr>  
                {% endfor %}              
                </tbody>
            </table>  
        </div> 
    
        <div class="cart-total">
            <table id="total">
                <tbody>
             <!--   <tr>
                        <td class="right"><b>Sub-Total:</b></td>       
                        <td class="right">$710.50</td>
                    </tr>  --> 
                    <tr>
                        <td class="right"><b>Total:</b></td>
                        
                        <td class="right">{{Total}} €</td>
                       
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="buttons">    
        	{% if user.is_authenticated %} 
   				<div class="right"><a class="button"  href="{% url 'registro_Compra' user.id %}">Confirmar Compra</a></div>
    		{% else %}
    			<div class="right"><a class="button" href="{% url 'loginCompra' %}">Confirmar Compra</a></div>
    		{% endif %}
            
            <div class="left"><a class="button" href="{% url 'apps.catalog.views.remove_all_to_cart' %}">Vaciar Carrito</a></div>            
            <div class="center"><a class="button" href="{% url 'catalog_base' %}">Continuar Comprando</a></div>
        </div>        
      
      <div class="clear"></div>     
            
    </form>              
</div>
{% endblock %}